home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / Projects / Questions & Answers / Q&A Common Mistakes / Debugging Session2 < prev   
Encoding:
Text File  |  1998-10-26  |  5.5 KB  |  209 lines  |  [TEXT/ScoM]

  1. In the following code I'm trying to make some melodies which get selected 
  2. randomly. I get an illegal symbol value in the def-symbol. Also the def-length 
  3. uses the latest entry (all eighth notes). How can I somehow connect the 
  4. melody with its lengths.? (riff1=r1len)
  5.  
  6. ;random berry wheel generator
  7. ;riffs are berry leads + or - n adds accidentals
  8. ;how to keep melody with specific ryhtymn?
  9.  
  10. (setq riff1 '(df df df (-1 c e) a (-1 c e)))
  11. (setq riff2 '(he df (-1 c e) a he df (-1 c) e a))
  12.  
  13. (def-length
  14.     r1len '(1/4 1/4 1/8 1/8 1/8 1/8)
  15.     r2len '(1/8 1/8 1/8 1/8 1/8 1/8))
  16.  
  17. (def-channel
  18.     lead 1)
  19.  
  20. (def-tonality
  21.    lead (activate-tonality (major f 5)))
  22.  
  23. (setq rifzone1 (bars-to-zones '(1) '(4/4)))
  24. (setq rifzone2 (bars-to-zones '(1) '(4/4)))
  25.  
  26. several errors in the following:
  27.  
  28. (def-symbol
  29.    lead (append (gen-random 0.12 32 (list rifzone1 rifzone2))))
  30.  
  31. error1: you cannot use rifzones to define symbols, they are zones
  32. that you are using to define zones.
  33. error2: you are appending...but you are not appending anything,
  34.  append has only one argument which is the (gen-random ...).
  35.  
  36. (midiport :modem)
  37. (def-tempo 120)
  38. (compile-instrument "ccl;output:" "aberry wheel" lead)
  39.  
  40. to select elements randomly use pick-random.
  41.  
  42.  
  43. (setq random-seed 0.123)
  44.  
  45. (setq riff1 '(df df df (-1 c e) a (-1 c e)))
  46. (setq riff2 '(he df (-1 c e) a he df (-1 c) e a))
  47.  
  48. (setq r1len '(1/4 1/4 1/8 1/8 1/8 1/8))
  49. (setq r2len '(1/8 1/8 1/8 1/8 1/8 1/8))
  50.  
  51. ; initialize random generator with the seed value, and pick up a random
  52. ; value from riff1 and riff2
  53.  
  54. (init-rnd random-seed)
  55. (setq random-symbol (pick-random (list riff1 riff2)))
  56.  
  57. ; intialize the random generator again to ensure that it picks up the 
  58. ; corresponding length pattern. If you want to select also the length
  59. ; pattern randomly then initialize the generator with another seed.
  60. ; Notice that you must change the seed each time when you evaluate the
  61. ; file, otherwise it produces each time the same piece. 
  62.  
  63. (init-rnd random-seed)
  64. (setq random-length (pick-random (list r1len r2len)))
  65.  
  66. ; define the symbol and length contents for instr1
  67.  
  68. (def-symbol
  69.     instr1 random-symbol
  70. )
  71.  
  72. (def-length
  73.     instr1 random-symbol
  74. )
  75.  
  76. ;;;;;;;;;if you are targeting to pick up matching symbol lenght pairs
  77.  
  78. ; here you set up source material in a list. The list contains
  79. ; lists of symbols and corresponding lenghts. 
  80.  
  81. (setq source-material '(
  82.     ; first symbol length pair
  83.     ((df df df (-1 c e) a (-1 c e))
  84.      (1/4 1/4 1/8 1/8 1/8 1/8))
  85.     ; second 
  86.     ((he df (-1 c e) a he df (-1 c) e a)
  87.      (1/8 1/8 1/8 1/8 1/8 1/8))
  88.     ; add any number of similar pairs ..
  89. ))
  90.  
  91. (init-rnd 0.123)
  92. (setq random-pair (pick-random source-material))
  93.  
  94. ; now random-pair contains a pair list ((df df df (-1 c e) a (-1 c e)) (1/4 1/4 1/8 1/8 1/8 1/8))
  95.  
  96. ; set the first element to random-symbol
  97.  
  98. (setq random-symbol (nth 0 random-pair))
  99.  
  100. ; set the second element to random-lenght
  101.  
  102. (setq random-length (nth 1 random-pair))
  103.  
  104. (def-symbol
  105.     instr1 random-symbol
  106. )
  107.  
  108. (def-length
  109.     instr1 random-symbol
  110. )
  111.  
  112.  
  113. ;;
  114.  
  115. >I got my random chuck berry solo wheel to start working. but I feel the
  116. >solution is not very elegalant. The following code shows the progress. 
  117. >
  118. >;random berry wheel generator
  119. >;riffs are berry leads + or - n adds accidentals
  120. >;how to keep melody with specific ryhtymn?
  121. >(setq riff1 '(df df df (-1 c e) a (-1 c e)))
  122. >(setq riff2 '(he df (-1 c e) a he df (-1 c e) a))
  123. >(setq riff3 '(he he he he he df (-1 c e) df))
  124. >
  125. >(def-length
  126. >    lead1 '(1/4 1/4 1/8 1/8 1/8 1/8)
  127. >    lead2 '(1/8 1/8 1/8 1/8 1/8 1/8))
  128. >
  129. >(def-channel
  130. >    lead1 1
  131. >    lead2 1
  132. >)
  133. >
  134. >(def-tonality
  135. >   lead1 (activate-tonality (major f 5))
  136. >   lead2 (activate-tonality (major f 5)))
  137. >
  138. >(setq rifzone1 (bars-to-zones '(-1 1 -1 1) '(4/4 4/4 4/4 4/4)))
  139. >(setq rifzone2 (bars-to-zones '(1 -1 1 -1) '(4/4 4/4 4/4 4/4)))
  140. >
  141. >(def-zone
  142. >  lead1 rifzone1
  143. >  lead2 rifzone2)
  144. >
  145.  
  146. you dont need the append here
  147.  
  148. >(def-symbol
  149. >   lead1 (append (gen-random 0.12 32 (list riff1 riff2)))
  150. >   lead2 (append (gen-random 0.12 32 (list riff2 riff3))))
  151. >
  152. >(midiport :modem)
  153. >(def-tempo 120)
  154. >(compile-instrument "ccl;output:" "aberry wheel" lead1 lead2)
  155. >
  156. >I want to add some percussion now. How do I do that using zones? 
  157. >
  158. >In nigel's tutorial he says to evaluate the expression mt-32 to view drum
  159. >mapping. I tried that and got "null complier" I tried  (setq percussion mt-32)
  160. >and just got note numbers.  Do you have to activate-tonality mt-32 for drums?
  161.  
  162. You can examine things and learn to find solutions to problems like
  163. the above by yourself. I'll show you how. Highlite the following
  164.  
  165. (activate-tonality (major f 5))
  166.  
  167. and the press eval button (one shimney)
  168.  
  169. you'll get
  170.  
  171. --> ((f 5 g 5 a 5 |A#| 5 c 6 d 6 e 6))
  172.  
  173. Now, highlite mt-32 and press the eval button (one shimney).
  174. What do you get?
  175.  
  176. You'll get
  177.  
  178. -->((b 2 c 3 c# 3 d 3 d# 3 e 3 f 3 f# 3 g# 3 a 3 a# 3 c 4 c# 4 d# 4 f# 4 g# 4 c 5 c# 5 d 5 d# 5 e 5 f 5 f# 5 g 5 g# 5 a 5 a# 5 b 5 c 6 c# 6 d# 6))
  179.  
  180. By a quick look you can say they both represent tonalities.
  181.  
  182. Since now you know that mt-32 is a tonality you can use it to define
  183. a tonality for an instrument.
  184.  
  185. (def-tonality
  186.    lead1 (activate-tonality (major f 5))
  187.    lead2 (activate-tonality (major f 5))
  188.    drums mt-32
  189. )
  190.  
  191. Try the following, when you compile it what do you get? Try to
  192. predict that before compilation, and compare the prediction to what
  193. you get.
  194.  
  195. (def-symbol
  196.    drums '(a b c)
  197. )
  198.  
  199. >One more problem is that I can't seem to assign programs for my gm module.
  200. >(def-program gm-sound-set
  201. >   lead  electric-gutair-clean)
  202. >
  203.  
  204. When you get errors, check first that it is spelled right ;-). This
  205. will work.
  206.  
  207. (def-program gm-sound-set
  208.    lead  electric-guitar-clean)
  209.